package com.example.demo.controller;
import com.example.demo.model.Ob;
import com.example.demo.service.IObService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator 董婷
 */

@Api(tags = "出差管理")
@RestController
@RequestMapping("/swagger23")
public class obController {
    @Autowired
    private IObService obService;
    @CrossOrigin
    @ApiOperation(value="对出差信息的添加方法")
    @PostMapping("/insertob")
    public int insertOb(@RequestBody Ob ob){
        System.out.println("进入添加出差信息接口" );
        return obService.insertOb(ob);
    }

    @PostMapping("/getAll")
    public List<Ob> getAllOb(@RequestBody Ob ob)
    {
        System.out.println("进入出差信息查询方法");
        List<Ob> listOb=obService.getAllOb(ob);
        return listOb;
    }
    @PostMapping("/editOb")
    public int EditOb(@RequestBody Ob ob){
        System.out.println("添加出差信息修改方法");
        return obService.updateOb(ob);
    }
    @GetMapping("/delOb")
    public int Delete(int obid){
        System.out.println("进入删除出差信息方法");
        int returnValues=0;
        if(obid!=0){
            Ob ob=new Ob();
            ob.setObid(obid);
            returnValues=obService.deleteOb(ob);
        }
        return returnValues;
    }

    @GetMapping("/getOne")
    public Ob getOb(int obid){
        Ob ob=new Ob();
        System.out.println("进入单条查询出差信息方法");
        if(obid!=0){
            Ob ob1=new Ob();
            ob1.setObid(obid);
            ob=obService.getOb(ob1);
            System.out.println("返回的数据集合为:"+ob.getObid());
        }
        return ob;
    }








}
